package com.xdhl.fu.member.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xdhl.fu.common.core.web.domain.AjaxResult;
import com.xdhl.fu.member.domain.District;
import com.xdhl.fu.member.service.IDistrictService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 区/县控制器
 *
 * @author 朱力维
 * @time 2022/7/2 16:11
 */
@RestController
@RequestMapping("/district")
public class DistrictController {
    @Resource
    private IDistrictService districtService;

    /**
     * 根据城市Id获取区/县列表
     *
     * @return 指定城市的区/县列表
     */
    @GetMapping("/{districtUpId}")
    public AjaxResult getCityByProvinceId(@PathVariable String districtUpId) {
        LambdaQueryWrapper<District> condition = new LambdaQueryWrapper();
        condition.eq(District::getDistrictUpId, districtUpId);
        List<District> list = districtService.list(condition);
        return AjaxResult.success(list);
    }
}
